Skip to content

fix: add pytest plugin for caplog integration#97

Merged
svaningelgem merged 7 commits into
masterfrom
claude/fix-logprise-logcap-S5zBD
May 27, 2026
Merged

fix: add pytest plugin for caplog integration#97
svaningelgem merged 7 commits into
masterfrom
claude/fix-logprise-logcap-S5zBD

Conversation

@svaningelgem
Copy link
Copy Markdown
Owner

  • Create pytest plugin that forwards loguru logs to caplog fixture
  • Register plugin as pytest11 entry point so it loads automatically
  • Bypass standard logging to avoid recursion with InterceptHandler
  • Support caplog level filtering via at_level() context manager
  • Add comprehensive tests for caplog integration

Closes #94 : logs output via logprise don't show up in caplog.

claude and others added 4 commits January 20, 2026 12:57
- Create pytest plugin that forwards loguru logs to caplog fixture
- Register plugin as pytest11 entry point so it loads automatically
- Bypass standard logging to avoid recursion with InterceptHandler
- Support caplog level filtering via at_level() context manager
- Add comprehensive tests for caplog integration

Closes the issue where logs output via logprise don't show up in caplog.
Type the loguru sink parameter as loguru.Message and the record helper
as loguru.Record instead of object/dict. This removes the incorrect
'type: ignore[union-attr]' comment (mypy reported attr-defined) that was
failing the stubtest lint step in CI, and cast the loguru RecordException
to the exc_info type expected by logging.LogRecord.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.57%. Comparing base (701ed2f) to head (4d2986a).

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #97       +/-   ##
===========================================
- Coverage   99.50%   72.57%   -26.94%     
===========================================
  Files           1        2        +1     
  Lines         203      237       +34     
  Branches       35       37        +2     
===========================================
- Hits          202      172       -30     
- Misses          0       63       +63     
- Partials        1        2        +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The logprise pytest plugin (pytest11 entry point) already forces
logprise to load at pytest startup, so the per-test inline imports
provided no lazy-loading benefit and only triggered ruff PLC0415.
Move the single import to the module top level.
- Add a direct test for the sink's no-fixture early-return branch.
- Reload the plugin module once via a session-scoped autouse fixture so
  its import-time definitions (loaded at pytest startup, before coverage
  begins) are measured.
- Add codecov.yml requiring 100% patch coverage on every change, with
  project coverage held at no-regression.
- Add a 'Testing with caplog' section explaining the auto-loaded pytest
  plugin that surfaces loguru/logprise logs in pytest's caplog fixture.
- Add PyPI version, Python versions, build, codecov coverage and license
  badges to the README header.
@svaningelgem svaningelgem merged commit fd5e880 into master May 27, 2026
9 of 10 checks passed
@svaningelgem svaningelgem deleted the claude/fix-logprise-logcap-S5zBD branch May 27, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using caplog in pytest doesn't trigger anything

2 participants